package cn.udrm.elasticsearch.schedule;

import cn.udrm.elasticsearch.service.DirectoryRecurse2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Configuration
@Component
@Slf4j
public class CreateIndexTask {
    @Autowired
    private DirectoryRecurse2 directoryRecurse;

    @Value("${es.index-root}")
    private String indexRoot;

    @Scheduled(cron = "* 0/100  * * * ?")
    private void addIndex(){
        try {
            directoryRecurse.setTotal(0);
            //directoryRecurse.find(indexRoot);
            //directoryRecurse.writeIndexStatus();
        } catch (Exception e) {
            log.error("调度失败",e);
        }
    }
}
